package com.dc.refactoring._1_重新组织函数._4_ReplaceTempWithQuery;

/**
 * Description: 以查询取代临时变量 修改前
 * @author: gdc
 * @date: 2020/11/13
 * @version 1.0
 */
public class Test1 extends BaseClass {

    public double getPrice() {
        // 获取基础价格
        int basePrice = _itemPrice * _quantity;

        // 计算折扣
        double discountFactor;
        if (basePrice > 1000) {
            discountFactor = 0.95;
        } else {
            discountFactor = 0.98;
        }

        // 获取结果
        return basePrice * discountFactor;
    }
}
